<template>
  <div :class="[`nav-theme-${navTheme}`, `nav-layout-${navLayOut}`]">
    <a-layout
      id="components-layout-demo-custom-trigger"
      style="min-height: 100vh"
    >
      <a-layout-sider
        v-if="navLayOut === 'left'"
        :theme="navTheme"
        v-model="collapsed"
        width="256px"
        :trigger="null"
        collapsible
      >
        <div class="logo">Ant Design vue pro</div>
        <SideMenu :theme="navTheme" />
      </a-layout-sider>
      <a-layout>
        <a-layout-header style="background: #fff; padding: 0">
          <a-icon
            v-auth="['admin']"
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="() => (collapsed = !collapsed)"
          />
          <Header />
        </a-layout-header>
        <a-layout-content style="margin: 0 16px">
          <router-view></router-view>
        </a-layout-content>
        <a-layout-footer style="text-align: center">
          <Footer />
        </a-layout-footer>
      </a-layout>
    </a-layout>
    <Authorized :authority="['admin']">
      <SettingDrawer />
    </Authorized>
  </div>
</template>

<script>
import Header from "./Header";
import Footer from "./Footer";
import SideMenu from "./SideMenu";
import SettingDrawer from "../components/SettingDrawer";
import Authorized from "@/components/Authorized";
export default {
  name: "BasicLayout",
  data() {
    return {
      collapsed: false,
    };
  },
  computed: {
    navTheme() {
      return this.$route.query.navTheme || "dark";
    },
    navLayOut() {
      return this.$route.query.navLayOut || "left";
    },
  },
  components: {
    Authorized,
    Header,
    Footer,
    SideMenu,
    SettingDrawer,
  },
};
</script>

<style scoped>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
}
.logo {
  height: 30px;
  line-height: 30px;
  text-align: center;
  overflow: hidden;
}

.nav-theme-dark >>> .logo {
  color: #fff;
}
</style>
